import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:getxdemo/res/colors.dart';

/// 通用按钮
class NormalButton extends StatelessWidget {
  final bool enable;
  final VoidCallback onPressed;
  final String title;
  final double height;
  final double width;
  final EdgeInsetsGeometry? margin;
  final double fontSize;

  const NormalButton({
    Key? key,
    this.enable = true,
    required this.onPressed,
    required this.title,
    this.height = 50,
    this.width = double.infinity,
    this.margin,
    this.fontSize = 18,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: height,
      width: width,
      margin: margin,
      decoration: BoxDecoration(
        color: enable ? ColorStyle.color_24CF5F : ColorStyle.color_24CF5F_20,
        borderRadius: const BorderRadius.all(Radius.circular(30))
      ),
      child: TextButton(
          onPressed: onPressed,
          style: ButtonStyle(
            overlayColor:MaterialStateProperty.all(ColorStyle.colorShadow),
            animationDuration: const Duration(milliseconds: 200),
            padding: MaterialStateProperty.all(const EdgeInsets.all(0)),
            shape:MaterialStateProperty.all(const StadiumBorder())
          ),
          child: Text(
            title,
            style: TextStyle(
                color: enable ? Colors.white : Colors.white24, fontSize: fontSize),
          )),
    );
  }
}
